package LatentTicTacToe.misc;

/**
 * Static class for cloning 2-D arrays
 * 
 * @author Jiri Cermak
 *
 */
public class Cloner {

	public static byte[][] clone(byte[][] source, byte[][] destination) {
		for (int i = 0; i < destination.length; i++) {
			for (int j = 0; j < destination[0].length; j++) {
				destination[j][i] = source[j][i];
			}
		}

		return destination;
	}

	public static int[][] clone(int[][] source, int[][] destination) {
		for (int i = 0; i < destination.length; i++) {
			for (int j = 0; j < destination[0].length; j++) {
				destination[j][i] = source[j][i];
			}
		}

		return destination;
	}

	public static byte[][] clone(byte[][] source) {

		byte[][] destination = new byte[source[0].length][source.length];

		for (int i = 0; i < destination.length; i++) {
			for (int j = 0; j < destination[0].length; j++) {
				destination[j][i] = source[j][i];
			}
		}

		return destination;
	}

	public static int[][] clone(int[][] source) {

		int[][] destination = new int[source[0].length][source.length];

		for (int i = 0; i < destination.length; i++) {
			for (int j = 0; j < destination[0].length; j++) {
				destination[j][i] = source[j][i];
			}
		}

		return destination;
	}
}
